// JKLogin

//商家的登录
function JKStoreLogin(pn, pw, authority) {
	
		JKjsonP({
			ws:"merchants/login",
			parameter:{username:pn, password:pw, authority:authority},
			sFunc:function(json){
				if(json.result=="success"){
					localStorage.setItem("shopid", json.data.shop.id);
				var nextPage;
				if(authority=="main") {
					nextPage = "main.html";
					localStorage.setItem("master_mobileno", json.telNo);	
				}else if(authority=="distribution") {
					nextPage = "distribution.html";	
				}else if(authority=="delivery") {
					nextPage = "delivery.html";	
				}
				localStorage.setItem("LoginName", pn);
				window.location.href=nextPage;
				}
				
			},
			eFunc:function(XMLHttpRequest, textStatus, emessage){
				messageBox("服务器解析数据错误");
			}
		});		
}
	
function JKSalesLogin(pn, pw){
	JKjsonP({
			ws:"sales/login",
			parameter:{telephone:pn, password:pw,authority:"sale"},
			sFunc:function(json){
				if(json.result=="success"){
					localStorage.setItem("saleAdminId",json.data.saleAdmin.id);
					localStorage.setItem("telephone",json.data.saleAdmin.telephone);
					localStorage.setItem("salesmanName",json.data.saleAdmin.salesmanName);
					localStorage.setItem("bankName",json.data.saleAdmin.bankName);
					localStorage.setItem("bankCardNo",json.data.saleAdmin.bankCardNo);
					window.location.href="main.html";
				}else{
					messageBox(json.msg);
				}
			},
			eFunc:function(XMLHttpRequest, textStatus, emessage){
				messageBox("服务器解析数据错误");
			}
		});		
}


	